package com.zero.qth.weixin.bean;

import com.zero.qth.weixin.config.WeixinPayConfig;
import com.zero.qth.weixin.pojo.Create;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
public class WeixinCreateBean {

    private final WeixinPayConfig weixinPayConfig;

    @Bean
    public Create create() {
        String mchid = weixinPayConfig.getMchId();
        String certificateSerialNo = weixinPayConfig.getCertSerialNo();
        String wechatPayPublicKeyId = weixinPayConfig.getWechatPubKeyId();
        String privateKeyFilePath = weixinPayConfig.getPrivateKeyPath();
        String wechatPayPublicKeyFilePath = weixinPayConfig.getWechatPayPublicKeyPath();
        return new Create(
                mchid,
                certificateSerialNo,
                privateKeyFilePath,
                wechatPayPublicKeyId,
                wechatPayPublicKeyFilePath
        );
    }

}
